package com.example.stumanager.admin;


import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

import com.example.stumanager.R;
import com.example.stumanager.adapter.LateReturnAdapter;
import com.example.stumanager.database.LateReturnSql;
import com.example.stumanager.entity.LateReturnEntity;

import java.util.ArrayList;
/**
 * 晚归打卡数据返回类
 */
public class AdminLateReturnPage extends AppCompatActivity {
    ListView list;
    Button re;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.admin_late_return_page);
        list = findViewById(R.id.lv_1);
        re = findViewById(R.id.re);
        re.setOnClickListener(view -> finish());
    }

    @Override
    protected void onStart() {
        super.onStart();
        set();
    }

    void set() {
        LateReturnSql db = new LateReturnSql(this);
        ArrayList array = db.getAll();

        LateReturnAdapter friendAdapter = new LateReturnAdapter(this, db.getAll());
        list.setAdapter(friendAdapter);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                String s = ((LateReturnEntity) array.get(i)).getName();
                Toast.makeText(AdminLateReturnPage.this, "姓名：" + s, Toast.LENGTH_SHORT).show();


            }
        });
    }


}
